package br.com.portalecbahia.customize;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class Loader implements Runnable {
    
	private Handler handler;
	private final Thread thread = new Thread(this);
	public void loading(Handler handler){
		 
		 this.handler = handler;
		 thread.start();
	}
	
	@Override
	public void run() {
		Bundle data = new Bundle();
		StringBuilder ellipsis = new StringBuilder();
		while(true){
			if(ellipsis.length()==3){
				ellipsis = new StringBuilder();
			}else{
				ellipsis.append(".");
			}
		
			data.putString("ellipsis", ellipsis.toString());
			
			Message msg = new Message();
			msg.setData(data);
							

			handler.sendMessage(msg);
			try {
				Thread.sleep(1000); // no need for a loop
			} catch (InterruptedException e) {
				Log.e("LongOperation", "Interrupted", e);
			}
		}
	}

}